package org.oos.model;

import java.io.Serializable;

/**
 * Represents the parameters used for bboxing a search.
 * 
 * @author pablo.gonzalez@11870.com
 * 
 */
public class BBox implements Serializable {

	private static final long serialVersionUID = 1L;
	
	private Float minLongitude;
	private Float minLatitude;
	private Float maxLongitude;
	private Float maxLatitude;

	public BBox(Float minLongitude, Float minLatitude, Float maxLongitude,
			Float maxLatitude) {
		super();
		this.minLongitude = minLongitude;
		this.minLatitude = minLatitude;
		this.maxLongitude = maxLongitude;
		this.maxLatitude = maxLatitude;
	}

	public Float getMinLongitude() {
		return minLongitude;
	}

	public void setMinLongitude(Float minLongitude) {
		this.minLongitude = minLongitude;
	}

	public Float getMinLatitude() {
		return minLatitude;
	}

	public void setMinLatitude(Float minLatitude) {
		this.minLatitude = minLatitude;
	}

	public Float getMaxLongitude() {
		return maxLongitude;
	}

	public void setMaxLongitude(Float maxLongitude) {
		this.maxLongitude = maxLongitude;
	}

	public Float getMaxLatitude() {
		return maxLatitude;
	}

	public void setMaxLatitude(Float maxLatitude) {
		this.maxLatitude = maxLatitude;
	}

	public int getLatSpanE6() {
		return (int) (Math.abs(getMaxLatitude() - getMinLatitude()) * 1e6);
	}

	public int getLonSpanE6() {
		return (int) (Math.abs(getMaxLongitude() - getMinLongitude()) * 1e6);
	}

	private final char COMMA = ',';

	@Override
	public String toString() {
		return new StringBuilder().append(minLongitude).append(COMMA).append(
				minLatitude).append(COMMA).append(maxLongitude).append(COMMA)
				.append(maxLatitude).toString();
	}

}
